import Vue from 'vue'
import Router from 'vue-router'
// @指的是src目录
import Home from '@/home/Home'
import City from '@/city/City'
import Detail from '@/detail/Detail'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      // 加载异步组件，提升性能，当app.js比较大时使用，不然效果相反
      // component: () => import('@/home/Home'),
      meta: {
        title: '去哪儿'
      }
    }, {
      path: '/city',
      name: 'City',
      component: City,
      meta: {
        title: '城市定位'
      }
    }, {
      // 通过:id设置动态路由
      path: '/detail/:id',
      name: 'Detail',
      component: Detail,
      meta: {
        title: '城市定位'
      }
    }
  ],
  // 清除首页滚动对detail页面的影响
  scrollBehavior (to, from, savedPosition) {
    // return 期望滚动到哪个的位置
    return { x: 0, y: 0 }
  }
})
